743A - Vladik and flights - CodeForces Solution


constructive algorithms greedy implementation *1200

Please click on ads to support us..

Python Code:

n,a,b = list(map(int, input().split()))
s = input()
a-=1
b-=1
        
print((ord(s[a])-58) ^ (ord(s[b])-58))

C++ Code:

#include <bits/stdc++.h>
#define ll long long
#define ui int 
#define ff first
#define ss second
#define pb push_back
#define mp  make_pair
#define pii pair<int,int>
#define vi  vector<int>
#define mii map<int,int>
#define w(x) int x; cin>>x; while(x--)
using namespace std;
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    vector<char> i(n);
    for(int j = 0; j < n;j++){
      cin >> i[j];
    };
    char x = i[a - 1];
    if(i[a -1] != i[b-1]){
      cout << 1;
    }else{
      cout << 0;
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

1613A - Long Comparison
1624B - Make AP
660B - Seating On Bus
405A - Gravity Flip
499B - Lecture
709A - Juicer
1358C - Celex Update
1466B - Last minute enhancements
450B - Jzzhu and Sequences
1582C - Grandma Capa Knits a Scarf
492A - Vanya and Cubes
217A - Ice Skating
270A - Fancy Fence
181A - Series of Crimes
1638A - Reverse
1654C - Alice and the Cake
369A - Valera and Plates
1626A - Equidistant Letters
977D - Divide by three multiply by two
1654B - Prefix Removals
1654A - Maximum Cake Tastiness
1649A - Game
139A - Petr and Book
1612A - Distance
520A - Pangram
124A - The number of positions
1041A - Heist
901A - Hashing Trees
1283A - Minutes Before the New Year
1654D - Potion Brewing Class